package com.crm.miaohe.mapper;

import com.crm.miaohe.model.MstRole;
import com.crm.miaohe.model.MstRoleExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface MstRoleMapper {
    long countByExample(MstRoleExample example);

    int deleteByExample(MstRoleExample example);

    @Delete({
        "delete from mst_role",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into mst_role (role_name, create_time, ",
        "create_user, update_time, ",
        "update_user, version)",
        "values (#{roleName,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, ",
        "#{createUser,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, ",
        "#{updateUser,jdbcType=VARCHAR}, #{version,jdbcType=BIGINT})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insert(MstRole record);

    int insertSelective(MstRole record);

    List<MstRole> selectByExample(MstRoleExample example);

    @Select({
        "select",
        "id, role_name, create_time, create_user, update_time, update_user, version",
        "from mst_role",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @ResultMap("com.crm.miaohe.mapper.MstRoleMapper.BaseResultMap")
    MstRole selectByPrimaryKey(Long id);

    int updateByExampleSelective(@Param("record") MstRole record, @Param("example") MstRoleExample example);

    int updateByExample(@Param("record") MstRole record, @Param("example") MstRoleExample example);

    int updateByPrimaryKeySelective(MstRole record);

    @Update({
        "update mst_role",
        "set role_name = #{roleName,jdbcType=VARCHAR},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "create_user = #{createUser,jdbcType=VARCHAR},",
          "update_time = #{updateTime,jdbcType=TIMESTAMP},",
          "update_user = #{updateUser,jdbcType=VARCHAR},",
          "version = #{version,jdbcType=BIGINT}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(MstRole record);
}